import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;

public class Test {
    public static void main(String[] args) {

    }
    public static void main3(String[] args) {
        Set<String> set=new TreeSet<>();
        set.add("abc");
        set.add("ok");
        set.add("ko");
        set.add("main");
        System.out.println(set);
    }
    public static void main2(String[] args) {
        Map<String,Integer> map=new TreeMap<>();
        map.put("hello",1);
        map.put("key",2);
        map.put("ko",3);
        Set<Map.Entry<String,Integer>> entries=map.entrySet();//放在容器里
        // Map.Entry<String,Integer>Entry是Map里的一个内部接口，相当一个容器来接受k，v键值对
        for (Map.Entry<String,Integer> entry : entries){
            String key=entry.getKey();
            Integer val=entry.getValue();
            System.out.println("key: "+key+" val"+val);
        }
        Set<String> strings=map.keySet();
        System.out.println(strings);
        Integer val=map.getOrDefault("abc2",999);
        System.out.println(val);
        map.remove("ko");
        val=map.get("ko");
        System.out.println(val);
    }
    public static void main1(String[] args) {
        int[] array={5,10,3,1,15};
        BinarySearchTree binarySearchTree=new BinarySearchTree();
        for (int i = 0; i <array.length ; i++) {
            binarySearchTree.insert(array[i]);
        }
        System.out.println(binarySearchTree.search(15));
        binarySearchTree.remove(15);
        System.out.println(binarySearchTree.search(15));
    }
}
